<?php 
session_start();
set_include_path(get_include_path() . PATH_SEPARATOR . 'admin');
include_once "includes/Utilisateur.inc.php";
include_once "includes/Constantes.inc.php";

$ok = true;

if(!isset($_POST["login"]) || ($_POST["login"] == "")){
	$ok = false;
}
else {
	$idUtil = searchUtilisateurByLogin($_POST["login"]);
	
	if(!isset($idUtil) || ($idUtil == "")){
		$ok = false;
	}
	else {
		$utilisateur = getUtilisateur($idUtil[0]);
		
		if(($_POST["password"]) != ($utilisateur->getPassword())){
			$ok = false;
		}
	}
}
if($ok == false){
	//Mauvais password
	header("Location: connexion.php?result=ko");
	exit;
}
else {
	//Si password OK, on continue sur la navigation
	$_SESSION["login"] = $_POST["login"];
	header("Location: index.php");
	exit;
}
?>